package top.toptimus.dto.customerInfo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import top.toptimus.util.ValueUtil;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;

@NoArgsConstructor
@Data
@AllArgsConstructor
public class CustomerFitRDTO {
    private String itemCd;//人尺寸CD
    private String itemValue;//人尺寸VALUE
    private String fitValue;//人尺寸
    private String fitCountId;//CountId
    private String propertyNameCn;//人尺寸类别名称
    private String remarks;//衣服尺寸VALUE
    private String itemNameCn;//人量体名称

    public CustomerFitRDTO(ResultSet resultSet) throws SQLException {
        this.itemCd = ValueUtil.StringNullValue(resultSet.getString("itemCd"));
        this.itemValue = ValueUtil.StringNullValue(resultSet.getString("itemValue"));
        this.fitValue = ValueUtil.StringNullValue(resultSet.getString("fitValue"));
        this.fitCountId = ValueUtil.StringNullValue(resultSet.getString("fitCountId"));
        this.propertyNameCn = ValueUtil.StringNullValue(resultSet.getString("propertyNameCn"));
        this.remarks = ValueUtil.StringNullValue(resultSet.getString("remarks"));
        this.itemNameCn = ValueUtil.StringNullValue(resultSet.getString("itemNameCn"));
    }

    public CustomerFitRDTO(Map<String, Object> stringObjectMap) {
        this.itemCd = stringObjectMap.containsKey("itemCd") ? ValueUtil.StringNullValue(ValueUtil.objectToSting(stringObjectMap.get("itemCd"))) : "";
        this.itemValue = stringObjectMap.containsKey("itemValue") ? ValueUtil.StringNullValue(ValueUtil.objectToSting(stringObjectMap.get("itemValue"))) : "";
        this.fitValue = stringObjectMap.containsKey("fitValue") ? ValueUtil.StringNullValue(ValueUtil.objectToSting(stringObjectMap.get("fitValue"))) : "0";
        this.fitCountId = stringObjectMap.containsKey("fitCountId") ? ValueUtil.StringNullValue(ValueUtil.objectToSting(stringObjectMap.get("fitCountId"))) : "";
        this.propertyNameCn = stringObjectMap.containsKey("propertyNameCn") ? ValueUtil.StringNullValue(ValueUtil.objectToSting(stringObjectMap.get("propertyNameCn"))) : "";
        this.remarks = stringObjectMap.containsKey("remarks") ? ValueUtil.StringNullValue(ValueUtil.objectToSting(stringObjectMap.get("remarks"))) : "";
        this.itemNameCn = stringObjectMap.containsKey("itemNameCn") ? ValueUtil.StringNullValue(ValueUtil.objectToSting(stringObjectMap.get("itemNameCn"))) : "";
        this.fitValue = this.fitValue.trim().isEmpty() ? "0" : this.fitValue;
    }
}
